import Rte from 'editor/index'

export default function onCaretInput(editor: Rte) {
  const { caret } = editor.input.$refs

  caret.addEventListener('input', function (e) {
    console.log(e)

    const { inputType } = e as InputEvent

    switch (inputType) {
      case 'deleteByComposition':
      case 'deleteByCut':
      case 'deleteByDrag': {
        break
      }
      case 'deleteContent':
        break
      case 'deleteContentForward':
      case 'deleteContentBackward':
        editor.input.toolList()
        break
      case 'deleteEntireSoftLine': {
        break
      }
      case 'deleteHardLineBackward': {
        break
      }
      case 'deleteSoftLineBackward': {
        break
      }
      case 'deleteHardLineForward': {
        break
      }
      case 'deleteSoftLineForward': {
        break
      }
      case 'deleteWordBackward':
        break

      case 'deleteWordForward': {
        break
      }
      case 'insertLineBreak':
        break
      case 'insertParagraph':
        e.preventDefault()
        // editor.input.insertParagraph()
        break
      case 'insertFromComposition':
      case 'insertFromDrop':
      case 'insertFromYank':
      case 'insertReplacementText':
        break
      case 'insertFromPaste':
        e.preventDefault()
        // editor.input.insertFromPaste(Reflect.get(e, 'dataTransfer'))
        break
      case 'insertCompositionText':
        // 在 compositionend 中进行文字插入
        editor.input.deleteSelection()
        break
      case 'insertText': {
        editor.input.insertText()
        break
      }
    }
  })
}
